package hn.sigit.view.workflow.transaction;

import hn.sigit.model.hnd.ladmshadow.Restriction;
import hn.sigit.model.ladm.administrative.LA_RestrictionType;
import hn.sigit.model.ladm.external.ExtParty;
import hn.sigit.view.ShareValue;

public class ParcelRestriction extends ParcelRRR {
	private LA_RestrictionType rrrType;
	
	public ParcelRestriction(long presentationId, ExtParty extParty) {
		super(presentationId, extParty);
		this.rrr = Restriction.newRestriction(0, presentationId, false, false);
	}
	public ParcelRestriction(long presentationId, ExtParty extParty, ShareValue share, Restriction restriction) {
		super(presentationId, extParty, share);
		this.rrr = restriction;
	}
	
	@Override
	public LA_RestrictionType getRrrType() {
		return rrrType;
	}
	public void setRrrType(LA_RestrictionType rrrType) {
		this.rrrType = rrrType;
	}
	@Override
	public String getTypeString() {
		if (rrrType == null) return "";
		
		return rrrType.name();
	}
	
	
	public void cancelChanges() {
		if (rrr == null) return;
		
		super.cancelChanges();
		this.rrrType = ((Restriction) rrr).getType();
	}
	
	protected void applyChanges() {
		if (rrr == null) return;
		
		super.applyChanges();
		((Restriction) rrr).setType((LA_RestrictionType) rrrType);
	}
}
